#include <Box2D.h>
#include "common.h"

#ifdef __cplusplus
extern "C" {
#endif

JNIEXPORT jint JNICALL Java_b2RevoluteJoint_jniGetAnchorA
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetAnchorA();
	return (jint)vec;
}

JNIEXPORT jint JNICALL Java_b2RevoluteJoint_jniGetAnchorB
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetAnchorB();
	return (jint)vec;
}

JNIEXPORT jint JNICALL Java_b2RevoluteJoint_jniGetLocalAnchorA
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetLocalAnchorA();
	return (jint)vec;
}

JNIEXPORT jint JNICALL Java_b2RevoluteJoint_jniGetLocalAnchorB
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetLocalAnchorB();
	return (jint)vec;
}

JNIEXPORT jfloat JNICALL Java_b2RevoluteJoint_jniGetReferenceAngle
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	return joint->GetReferenceAngle();
}

JNIEXPORT jfloat JNICALL Java_b2RevoluteJoint_jniGetJointAngle
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	return joint->GetJointAngle();
}

JNIEXPORT jfloat JNICALL Java_b2RevoluteJoint_jniGetJointSpeed
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	return joint->GetJointSpeed();
}

JNIEXPORT jboolean JNICALL Java_b2RevoluteJoint_jniIsLimitEnabled
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	return joint->IsLimitEnabled();
}

JNIEXPORT void JNICALL Java_b2RevoluteJoint_jniEnableLimit
  (JNIEnv *env, jclass cls, jint addr, jboolean flag)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	joint->EnableLimit(flag);
}

JNIEXPORT jfloat JNICALL Java_b2RevoluteJoint_jniGetLowerLimit
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	return joint->GetLowerLimit();
}

JNIEXPORT jfloat JNICALL Java_b2RevoluteJoint_jniGetUpperLimit
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	return joint->GetUpperLimit();
}

JNIEXPORT void JNICALL Java_b2RevoluteJoint_jniSetLimits
  (JNIEnv *env, jclass cls, jint addr, jfloat lower, jfloat upper)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	joint->SetLimits(lower, upper);
}

JNIEXPORT void JNICALL Java_b2RevoluteJoint_jniEnableMotor
  (JNIEnv *env, jclass cls, jint addr, jboolean flag)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	joint->EnableMotor(flag);
}

JNIEXPORT jboolean JNICALL Java_b2RevoluteJoint_jniIsMotorEnabled
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	return joint->IsMotorEnabled();
}

JNIEXPORT jfloat JNICALL Java_b2RevoluteJoint_jniGetMotorSpeed
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	return joint->GetMotorSpeed();
}

JNIEXPORT void JNICALL Java_b2RevoluteJoint_jniSetMotorSpeed
  (JNIEnv *env, jclass cls, jint addr, jfloat speed)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	joint->SetMotorSpeed(speed);
}

JNIEXPORT jfloat JNICALL Java_b2RevoluteJoint_jniGetMaxMotorTorque
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	return joint->GetMaxMotorTorque();
}

JNIEXPORT void JNICALL Java_b2RevoluteJoint_jniSetMaxMotorTorque
  (JNIEnv *env, jclass cls, jint addr, jfloat torque)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	joint->SetMaxMotorTorque(torque);
}

JNIEXPORT jint JNICALL Java_b2RevoluteJoint_jniGetReactionForce
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetReactionForce();
	return (jint)vec;
}

JNIEXPORT jfloat JNICALL Java_b2RevoluteJoint_jniGetReactionTorque
  (JNIEnv *env, jclass cls, jint addr, jfloat torque)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	return joint->GetReactionTorque();
}

JNIEXPORT jfloat JNICALL Java_b2RevoluteJoint_jniGetMotorTorque
  (JNIEnv *env, jclass cls, jint addr, jfloat inv_dt)
{
	b2RevoluteJoint* joint = (b2RevoluteJoint*)addr;
	return joint->GetMotorTorque(inv_dt);
}

#ifdef __cplusplus
}
#endif
